﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace canyinguanlixitong
{
    public partial class frmaddsevers : Form
    {
        public frmaddsevers()
        {
            InitializeComponent();
        }
        string strconn = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";
        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            add();
          
        }
        public void add() {
            SqlConnection conn = new SqlConnection(strconn);
            conn.Open();
            int bianhao =Convert.ToInt32(this.textBox1.Text);
            string name = this.textBox2.Text;
            string sex = this.textBox4.Text;
            string iphone = this.textBox5.Text;
            string IDnum = this.textBox6.Text;
            string js = this.textBox7.Text;
            DateTime born=this.dateTimePicker1.Value;
            string sql = @"insert into dbo.UserTpye(userID,userName,userSex,userDian,userAdd,userBorn,userQi)
                values('"+bianhao+"','"+name+"','"+sex+"','"+iphone+"','"+IDnum+"','"+born+"','"+js+"')";
            SqlCommand cmd = new SqlCommand(sql,conn);
            int result = cmd.ExecuteNonQuery();
            if (result == 1)
            {
                MessageBox.Show("新增成功");
               
            }
            else {
                MessageBox.Show("新增失败");
            }

            conn.Close();
        }

        private void frmaddsevers_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
